<%@ include file="/common/taglibs.jsp"%>
<%@attribute name="date"  type="java.lang.String" required ="true"%>
<%@attribute name="readOnly"  type="java.lang.String" required ="false"%>

<c:choose>
<c:when test="${readOnly == true}">
<input name="${date}" style="width: 120px" readonly="readonly" maxlength="10">
<IMG  onmouseover="this.style.background='red';" title="selectDate" 
            style="VERTICAL-ALIGN: top;BORDER-RIGHT: red 1px solid; BORDER-TOP: red 1px solid; BORDER-LEFT: red 1px solid; CURSOR: pointer; BORDER-BOTTOM: red 1px solid" 
            onmouseout="this.style.background=''" 
            src="${pageContext.request.contextPath}/common/jscalendar-1.0/img.gif">&nbsp;&nbsp;

</c:when>

<c:otherwise>
<form:input htmlEscape="true" path="${date}"  cssStyle="width: 120px"  size="10"  readonly="false"/>

<c:set var="dateFuncName" value="${fn:replace(date,'.','')}"/>

<IMG id="${date}_button" 
            onmouseover="this.style.background='red';" title="selectDate" 
            style="VERTICAL-ALIGN: top;BORDER-RIGHT: red 1px solid; BORDER-TOP: red 1px solid; BORDER-LEFT: red 1px solid; CURSOR: pointer; BORDER-BOTTOM: red 1px solid" 
            onmouseout="this.style.background=''" 
            src="${pageContext.request.contextPath}/common/jscalendar-1.0/img.gif">&nbsp;&nbsp;
<SCRIPT type=text/javascript>
                function update${dateFuncName}(cal){
          	      var date = cal.date;
        	    }	    			   
			    Calendar.setup({inputField     :    "${date}",
			    				ifFormat : "%Y-%m-%d %H:%M", // the date format
							    button         :    "${date}_button",
							    align          :    "Tl",
							    singleClick    :    true,
							    showsTime	   :    true,
							    onUpdate	   :	update${dateFuncName}

			    });
</SCRIPT>  
</c:otherwise>

</c:choose>


          

  <script language=JavaScript>
/*	function tabForInputText(self,next,size,event){
		var nextElemnet=document.getElementById(next);
		
		
		if(event.shiftKey||event.keyCode==16||event.keyCode==9){
			return;
		}
		
		if(self.value.length==size &&event.keyCode!=37&&event.keyCode!=39){
			spaceTrim(self);
			
			nextElemnet.focus();
		}
	}

	function spaceTrim(self){
		self.value= self.value.replace(/(^\s*)|(\s*$)/g,   "");
		
	}
	function addZero(self,size){
		if(self.value.length>0&&self.value!=" "){
		for(var i=0;self.value.length<size;i++){
			self.value='0'+self.value;
		}
		
		}
		spaceTrim(self);
	}
	*/
 </script language=JavaScript>
 

 

